package br.com.sgc.entities.geral;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import br.com.sgc.entities.medico.PlanoSaude;

@Entity
@Table(schema="geral")
@Inheritance(strategy = InheritanceType.JOINED)
public class Paciente implements Serializable{

	private static final long serialVersionUID = -113726081066525541L;
	
	@Id
	@SequenceGenerator(sequenceName="geral.seq_ficha_paciente", name="SEQ", allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE,  generator="SEQ")
	private Long id;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="plano_saude_id")
	private PlanoSaude planoSaude = new PlanoSaude();
	
	@Column(name="cartao_plano_saude")
	private String cartaoPlanoSaude;
	
	@Temporal(TemporalType.DATE)
	@Column(name="ultima_consulta")
	private Date ultimaConsulta;
	
	@OneToMany(mappedBy="paciente", fetch = FetchType.LAZY)
	private List<FichaPaciente> historico = new ArrayList<FichaPaciente>();
	
	@OneToMany(mappedBy="paciente", fetch = FetchType.LAZY)
	private List<FichaVacinacao> vacinas = new ArrayList<FichaVacinacao>();
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="clinica_id")
	private Clinica clinica = new Clinica();
	
	@Transient
	private String displayNome;

	public PlanoSaude getPlanoSaude() {
		return planoSaude;
	}

	public void setPlanoSaude(PlanoSaude planoSaude) {
		this.planoSaude = planoSaude;
	}

	public String getCartaoPlanoSaude() {
		return cartaoPlanoSaude;
	}

	public void setCartaoPlanoSaude(String cartaoPlanoSaude) {
		this.cartaoPlanoSaude = cartaoPlanoSaude;
	}

	public Date getUltimaConsulta() {
		return ultimaConsulta;
	}

	public void setUltimaConsulta(Date ultimaConsulta) {
		this.ultimaConsulta = ultimaConsulta;
	}

	public List<FichaPaciente> getHistorico() {
		return historico;
	}

	public void setHistorico(List<FichaPaciente> historico) {
		this.historico = historico;
	}

	public Clinica getClinica() {
		return clinica;
	}

	public void setClinica(Clinica clinica) {
		this.clinica = clinica;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	public String getDisplayNome(){
		return null;
	}
	
	public String getDisplayDocumento(){
		return null;
	}

	public List<FichaVacinacao> getVacinas() {
		return vacinas;
	}

	public void setVacinas(List<FichaVacinacao> vacinas) {
		this.vacinas = vacinas;
	}
	
}
